<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 队列
        class Queue {
            #items = [];
            // 出队列
            dequeue() {
                return this.#items.shift();
            }
            // 入队列
            enqueue(data) {
                this.#items.push(data);
            }
            // front 获取队头元素
            front() {
                return this.#items.at(0);
            }
            // 队列的大小
            size() {
                return this.#items.length;
            }
            // 判断队列是否为空
            isEmpty() {
                return this.#items.length === 0 ? true : false;
            }

            // 清空队列
            clear() {
                this.#items = [];
            }

            // 转换为字符串
            toString() {
                return this.#items.join(',');
            }
        }

        let queue = new Queue();
        queue.enqueue(1);
        queue.enqueue(2);
        queue.enqueue(3);
        queue.enqueue(45);
        queue.enqueue(112);
        queue.enqueue(121);
        queue.enqueue(1231);
        queue.enqueue(1321);
    </script>
</body>

</html>